package com.likan.chqjtgc.controller;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.likan.chqjtgc.commons.PageVo;
import com.likan.chqjtgc.commons.R;
import com.likan.chqjtgc.entity.BasicUser;
import com.likan.chqjtgc.enums.HttpStatus;
import com.likan.chqjtgc.service.BasicUserService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

/**
 * <p>
 * 用户基本信息表 前端控制器
 * </p>
 *
 * @author lxh
 * @since 2020-12-31
 */
@Api(tags = {"用户登录"})
@RestController
@RequestMapping("/login")
public class UserLoginController {

    private Logger log = LoggerFactory.getLogger(getClass());
    @Resource
    private BasicUserService asicUserService;


    @ApiOperation(value = "userName查询用户登录信息")
    @GetMapping("/getByuserName")
    public R getByuserName(@RequestParam("userName") String userName){
        try {
            return R.ok(asicUserService.getOne(new QueryWrapper<BasicUser>().eq("USER_NAME",userName)));
        } catch (Exception e) {
            log.error(e.getMessage(), e);
            return R.failed(new BasicUser(), HttpStatus.INTERNAL_SERVER_ERROR);
        }
    }

}
